package zhishuang.wang.sansi.playlist;

import zhishuang.wang.sansi.tools.ReturnData;

import java.util.List;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:12
 * @Email 1406110602@qq.com
 */

public class PageItem {
    private String id;
    private String name;
    private List<AreaItem> areaItemList;

    public PageItem(String id, String name, List<AreaItem> areaItemList) {
        this.id = id;
        this.name = name;
        this.areaItemList = areaItemList;
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        rd.setCode(1);
        String errorMes = "";
        if (this.id != null && this.name != null && this.areaItemList != null && this.id.length() != 0 && this.name.length() != 0 && this.areaItemList.size() != 0) {
            ReturnData checkRd = null;

            for(int i = 0; i < this.areaItemList.size(); ++i) {
                AreaItem item = (AreaItem)this.areaItemList.get(i);
                checkRd = item.checkParam();
                if (checkRd.getCode() != 0) {
                    errorMes = errorMes + "区域项错误信息：区域项ID：" + item.getId() + "；" + checkRd.getMessage();
                }
            }
        } else {
            errorMes = errorMes + "页面唯一ID、页面名称、区域项等必填；";
        }

        if (errorMes != null && errorMes.length() != 0) {
            rd.setMessage(errorMes);
        } else {
            rd.setCode(0);
        }

        return rd;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<AreaItem> getAreaItemList() {
        return this.areaItemList;
    }

    public void setAreaItemList(List<AreaItem> areaItemList) {
        this.areaItemList = areaItemList;
    }
}